<script setup>
import { ref, onMounted } from "vue"
import axios from "axios"
import { ElMessage } from "element-plus"
import { useRoute } from "vue-router"
let tableData = ref([])
const route = useRoute()
const GetData = () => {

    axios.get(`http://127.0.0.1:8000/shop/shopping/`)
        .then((response) => {
            tableData.value = response.data // 直接赋值，假设response.data是数组
        })
        .catch((error) => {
            ElMessage.error('数据获取失败')
            console.error(error)
        })
}

onMounted(() => {
    GetData()
})
</script>
<template>

    <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="id" label="ID" width="180" />
        <el-table-column prop="name" label="Name" width="180" />
        <el-table-column prop="price" label="Price" width="180" />
        <el-table-column prop="num" label="Num" width="180" />
    </el-table>
    <router-link :to="`/`">主页</router-link>
</template>
<style scoped>
</style>